package com.ideaction.controller;

import com.ideaction.game.utils.IpUtils;
import com.ideaction.globalconst.Result;
import com.ideaction.req.PlayerCommonReqBody;
import com.ideaction.req.PlayerSaveReqBody;
import com.ideaction.service.PlayerServiceImp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


@RestController
public class PlayerController {
    
    @Autowired
    private PlayerServiceImp playerServiceImp;
    
    /**
     * 保存客户端的整块数据
     *
     * @param playerSaveReqBody
     * @param request
     * @return
     */
    @PostMapping("/SavePlayer")
    public String savePlayer(@RequestBody PlayerSaveReqBody playerSaveReqBody, HttpServletRequest request) {
        return playerServiceImp.savePlayer(playerSaveReqBody, IpUtils.getClientIp(request));
    }
    
    @PostMapping("/ChangeName")
    public String changeName(@RequestBody PlayerCommonReqBody playerCommonReqBody) {
        return Result.build().response();
        //return playerServiceImp.changeName(playerCommonReqBody);
    }
    
    @PostMapping("/PhoneBind")
    public String phoneBind(@RequestBody PlayerCommonReqBody playerCommonReqBody) {
        return Result.build().response();
        //return playerServiceImp.phoneBind(playerCommonReqBody);
    }
    
    @PostMapping("CheckTimeStamp")
    public String checkTimeStamp(@RequestBody PlayerCommonReqBody playerCommonReqBody) {
        return Result.build().response();
        //return playerServiceImp.checkTimeStamp(playerCommonReqBody);
    }
    
    @PostMapping("ClearPlayer")
    public String clearPlayer(@RequestBody PlayerCommonReqBody playerCommonReqBody) {
        playerServiceImp.clearPlayer(playerCommonReqBody.getUserId());
        return Result.build().response();
    }
    
}
